<template>
  <div class="outer">
    <div class="box">
      <header class="header fix">
        <a href="javascript:;" class="backImg" @click="flightIndex"></a>
        <div class="dateTitle">选去程:{{$store.state.flight.go}}--{{$store.state.flight.back}}</div>
      </header>
      <div class="title fix">
        <div class="dateTab">
          <div class="container fix">
            <div class="itemDate" v-for="(item,index) in $store.state.flight.week"  :class="{'is-selected': item.flag}" @click="weelSel(index)">
              <p class="itemDateWeek">{{item.week}}</p>
              <p class="itemDateNum">{{item.day}}</p>
            </div>
          </div>
        </div>
        <div class="dateImg" @click="dateShow = true"></div>
      </div>
      <div class="travelPolicy fix" :class="{positiontop:toFlightData!==''}">
        <label for="travelPolicy" class="label ">仅显示符合差旅标准的航班</label>
        <input id="travelPolicy" type="checkbox" v-model="$store.state.flight.travelPolicyCheck" @click="travelPolicyClick($event)" />
      </div>
      <div class="noFlight" v-show="noFlight">{{noFlightInfo}}</div>
    </div>
    <section class="main" :class="noFlight ? 'main-height' : 'no-main-height'">
      <scroll :data="$store.state.flight.flightShowDetail" style="position: absolute;top: 0;left: 0;right: 0;bottom: 0">
      <ul class="content scroll" v-if="noList" @click="outerClick">
        <li class="list" v-for="(item,index) in $store.state.flight.flightShowDetail" @click="flightListDetail(item,index)">
          <div class="listSub fix">
            <div class="liL">
              <p class="startDate">{{item.fromTime}}</p>
              <p>{{item.fromInfo}}</p>
            </div>
            <div class="liLine">

            </div>
            <div class="liM">
              <p class="toDate">{{item.toTime}}</p>
              <p>{{item.toInfo}}</p>
            </div>
            <div class="liR">
              <p class="money"><span class="moneyIco">￥</span>{{item.lowestPrice}}</p>
              <p v-if="item.restSeatNum>=9" class="Ticket">有票</p>
              <p v-if="item.restSeatNum<9" class="Ticket">剩{{item.restSeatNum}}张</p>
            </div>
          </div>
          <div class="flightType fix">
            <span class="carrierInfo">{{item.carrierInfo}}&nbsp;&nbsp;|&nbsp;&nbsp;{{item.aircraftInfo}}</span>
            <span v-if="item.withinTwoHoursLowestPrice" class="lowPrice">低价</span>
          </div>
        </li>
      </ul>
      </scroll>
    </section>
    <footer>
      <mt-tabbar v-model="selected1" :fixed="true">
        <mt-tab-item id="排序" @click.native="popupVisible1 = true" size="large">
          <i slot="icon" class="iconfont icon-jiage"></i>
          排序
        </mt-tab-item>
        <mt-tab-item id="舱位" @click.native="popupVisible2 = true" size="large">
          <i slot="icon" class="iconfont icon-zuoyiseat"></i>
          舱位
        </mt-tab-item>
        <mt-tab-item id="综合筛选" @click.native="popupVisible3 = true" size="large">
          <i slot="icon" class="iconfont icon-zongheshaixuan-"></i>
          综合筛选
        </mt-tab-item>
      </mt-tabbar>
    </footer>
    <mt-popup v-model="popupVisible1 " position="bottom">
      <div v-for="(pop,index) in popInfo" class="popItem" :class="{activePop:pop.isSelected}" @click="popActive(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible2 " position="bottom">
      <div v-for="(pop,index) in popInfo1" class="popItem" :class="{activePop:pop.isSelected}"
           @click="popActive1(index)">
        {{pop.name}}<i class="iconfont icon-duihao r" v-show="pop.popShowCheck"></i>
      </div>
    </mt-popup>
    <mt-popup v-model="popupVisible3" position="bottom">
      <div class="filterBox fix">
        <div class="showSel">
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[0].tabInfos" v-show="tabInfo.a" @click="buxian(0,index)">
            <span class="showSelItem1">起飞</span><span class="showSelItem2 ell">{{tabInfo.listName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[1].tabInfos" v-show="tabInfo.a" @click="buxian(1,index)">
            <span class="showSelItem1">出发</span><span class="showSelItem2 ell">{{tabInfo.fromAirport}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[2].tabInfos" v-show="tabInfo.a" @click="buxian(2,index)">
            <span class="showSelItem1">到达</span><span class="showSelItem2 ell">{{tabInfo.toAirport}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[3].tabInfos" v-show="tabInfo.a" @click="buxian(3,index)">
            <span class="showSelItem1">机型</span><span class="showSelItem2 ell">{{tabInfo.aircrefTypeName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
          <p class="showSelItem fix" v-for="(tabInfo,index) in tabInfo[4].tabInfos" v-show="tabInfo.a" @click="buxian(4,index)">
            <span class="showSelItem1">航司</span><span class="showSelItem2 ell">{{tabInfo.carrierName}}</span><span class="showSelItem3"><i class="iconfont icon-close1"></i></span>
          </p>
        </div>
        <div class="empty" @click="emptySel">
          清空筛选
        </div>
      </div>
      <div class="tabBox fix">
        <div class="tab">
          <div class="tabItem"  :class="{activeTabItem:tab.istab}"  v-for="(tab,index) in tabs" @click="tabSel(index)">{{tab.name}}</div>
        </div>
        <div class="tabInfo">
          <!--起飞时间-->
          <div class="tabInfoItem"  v-show="a">
            <label v-for="(tabInfo,index) in tabInfo[0].tabInfos" @click="buxian(0,index)">
              <span class="tabInfoSubL">{{tabInfo.listName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--出发机场-->
          <div class="tabInfoItem"  v-show="b">
            <label v-for="(tabInfo,index) in tabInfo[1].tabInfos" @click="buxian(1,index)">
              <span class="tabInfoSubL">{{tabInfo.fromAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--到达机场-->
          <div class="tabInfoItem"  v-show="c">
            <label v-for="(tabInfo,index) in tabInfo[2].tabInfos" @click="buxian(2,index)">
              <span class="tabInfoSubL">{{tabInfo.toAirport}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--机型-->
          <div class="tabInfoItem"  v-show="d">
            <label v-for="(tabInfo,index) in tabInfo[3].tabInfos" @click="buxian(3,index)">
              <span class="tabInfoSubL">{{tabInfo.aircrefTypeName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
          <!--航空公司-->
          <div class="tabInfoItem"  v-show="e">
            <label v-for="(tabInfo,index) in tabInfo[4].tabInfos" @click="buxian(4,index)">
              <span class="tabInfoSubL">{{tabInfo.carrierName}}</span>
              <span class="tabInfoSubR" v-show="!tabInfo.a"></span>
              <i class="iconfont icon-duihao tabInfoSubR1" v-show="tabInfo.a"></i>
            </label>
          </div>
        </div>
      </div>
      <div class="queren" @click="queren">
        确认
      </div>
    </mt-popup>
    <toast  :toastInfo="toastInfo"></toast>
    <date tipDivText="去程" @dateClick="dateClick" @dateBack="dateBack" v-show="dateShow" :max="max" :openTime="openTime" backCustom="1"></date>
  </div>
</template>

<script>
  import { Navbar, TabItem ,Tabbar,Indicator} from 'mint-ui';
  import date from 'components/date.vue';
  import toast from 'components/toast.vue';
  import Scroll from "../../../common/scroll/scroll.vue"

  export default{
    data(){
      return {
        dateShow:false,
        a: true,
        b: false,
        c: false,
        d: false,
        e: false,
        selected1: '排序',//底部tab切换默认高亮
        popupVisible1: false,//底部上升  排序
        popupVisible2: false,//底部上升  舱位
        popupVisible3: false,//底部上升  综合筛选
        isActive: false,
        flightListForm: [],
        noList:true,
        updateTime:0,//定时初始值
        IntervalTime:'',//定时器
        toastInfo:'',
      }
    },
    components: {Navbar, TabItem, Tabbar, date,toast,Scroll},
    beforeRouteLeave (to, from, next) {
      clearInterval(this.IntervalTime);
      next();

    },
    methods: {
      outerClick(){
        if(this.updateTime >= 480){
          this.toastInfo = '操作超时,正在为您跟新航班列表';
          this.flightAjax();
        }
      },
      update(){
        var that = this;
        that.updateTime = 0;
        that.toastInfo = '';

        this.IntervalTime = setInterval(function () {
          if(that.updateTime >= 480){
            that.$vux.toast.show({
              type: 'cancel',
              text: '操作超时,正在为您跟新航班列表',
              time: 2500
            })
            clearInterval(that.IntervalTime);
          }else{
            that.updateTime++
          }

        },1000)
      },
      format(date, fmt) { //用来处理时间
        var o = {
          "M+": date.getMonth() + 1, //月份
          "d+": date.getDate(), //日
          "h+": date.getHours(), //小时
          "m+": date.getMinutes(), //分
          "s+": date.getSeconds(), //秒
          "q+": Math.floor((date.getMonth() + 3) / 3), //季度
          "S": date.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
          if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
      }, //返回一个日期格式
      dateBack(){
        this.dateShow = false;
      },
      dateClick(msg){
        this.dateShow = false;
        this.date = msg;
        this.$store.state.flight.openTime = msg;//传给时间插件的时间
        this.$store.state.flight.fromDate = msg;
        this.$store.state.flight.month = msg.substring(5, 7);
        this.$store.state.flight.day = msg.substring(8, 10);
        this.$store.state.flight.Sunday = msg.weekGet();
        this.flightAjax({date: 1});

        this.$store.commit('flightTimeContrast');
      },
      travelPolicyClick(e){
        this.$store.state.flight.travelPolicyCheck = e.target.checked;
        this.flightAjax();
      },
      buxian(k, index){
//        控制样式
        var arr = this.$store.state.flight.tabInfo[k].tabInfos;
        var errorNum = arr.length;
        if (index == 0) {
          for (var i = 1; i < arr.length; i++) {
            arr[i].a = false;
          }
          arr[0].a = true;
        } else {

          arr[index].a = !arr[index].a;

          for (var k = 0; k < arr.length; k++) {
            if (arr[k].a == false) {
              errorNum--;
              if (errorNum == 0) {
                arr[0].a = true;
              }
            } else {
              arr[0].a = false;
            }
          }
        }
      },//综合筛选单个点击
      queren(){
        var flight = this.$store.state.flight;
        flight.fromTimes = '';
        flight.fromAirportNames = '';
        flight.toAirportNames = '';
        flight.aircrafts = '';
        flight.carrierNameShorts = '';

        var arr0 = this.tabInfo[0].tabInfos;  // 起飞时间0
        if (arr0[0].a == true) {
          flight.fromTimes = '';
        } else {
          for (var i = 0; i < arr0.length; i++) {
            if (arr0[i].a == true) {
              flight.fromTimes += arr0[i].listName + ','
            }
          }
        }
        flight.fromTimes = this.fromTimes.substring(0, this.fromTimes.length - 1);

        var arr1 = this.tabInfo[1].tabInfos;  //出发机场1
        if (arr1[0].a == true) {
          flight.fromAirportNames = '';
        } else {
          for (var i = 0; i < arr1.length; i++) {
            if (arr1[i].a == true) {
              flight.fromAirportNames += arr1[i].fromAirport + ','
            }
          }
        }
        flight.fromAirportNames = this.fromAirportNames.substring(0, this.fromAirportNames.length - 1);

        var arr2 = this.tabInfo[2].tabInfos;  //到达机场2
        if (arr2[0].a == true) {
          flight.toAirportNames = '';
        } else {
          for (var i = 0; i < arr2.length; i++) {
            if (arr2[i].a == true) {
              flight.toAirportNames += arr2[i].toAirport + ','
            }
          }
        }
        flight.toAirportNames = this.toAirportNames.substring(0, this.toAirportNames.length - 1);

        var arr3 = this.tabInfo[3].tabInfos; //机型3
        if (arr3[0].a == true) {
          flight.aircrafts = '';
        } else {
          for (var i = 0; i < arr3.length; i++) {
            if (arr3[i].a == true) {
              flight.aircrafts += arr3[i].aircrefType + ','
            }
          }
        }
        flight.aircrafts = this.aircrafts.substring(0, this.aircrafts.length - 1);

        var arr4 = this.tabInfo[4].tabInfos; //航空公司4
        if (arr4[0].a == true) {
          flight.carrierNameShorts = '';
        } else {
          for (var i = 0; i < arr4.length; i++) {
            if (arr4[i].a == true) {
              flight.carrierNameShorts += arr4[i].carrierName + ','
            }
          }
        }
        flight.carrierNameShorts = this.carrierNameShorts.substring(0, this.carrierNameShorts.length - 1);

        this.popupVisible3 = false;
        this.flightAjax();
      },//综合筛选点击
      emptySel(){
        for (var i = 0; i < this.tabInfo.length; i++) {
          for (var j = 1; j < this.tabInfo[i].tabInfos.length; j++) {
            this.$store.state.flight.tabInfo[i].tabInfos[j].a = false;
          }
          this.$store.state.flight.tabInfo[i].tabInfos[0].a = true;
        }
        var flight = this.$store.state.flight;
        flight.fromTimes = '';
        flight.fromAirportNames = '';
        flight.toAirportNames = '';
        flight.aircrafts = '';
        flight.carrierNameShorts = '';

      },
      goRouter(){
        var navItem = this.selected.charAt(this.selected.length - 1);
        switch (navItem) {

        };
        this.$store.state.flight.fromDate = this.$store.state.flight.week[navItem].fromDate;

        this.$store.state.flight.selected = navItem;

        this.$store.state.flight.Sunday = this.$store.state.flight.week[navItem].week;
        this.flightAjax();
      }, //重新选择了星期
      weelSel(index){
        this.$store.state.flight.fromDate = this.$store.state.flight.week[index].fromDate;
        this.$store.state.flight.Sunday = '周' + this.$store.state.flight.week[index].week;
        this.$store.state.flight.month = this.$store.state.flight.fromDate.substring(5, 7);
        this.$store.state.flight.day = this.$store.state.flight.fromDate.substring(8, 10);
        this.flightAjax({date: 2});
        this.$store.commit('flightTimeContrast');
      }, //重新选择了星期
      flightIndex(){
        this.$router.go(-1);
      },
      flightListDetail(item,index){
        this.$store.state.flightTo.index = index;
        this.$store.state.flightTo.currentList = item;
        this.$router.push({
          path: '/flight/toflightListDetail',
          query: {
            carrierCode: item.carrier.code,
            fromAirport: item.fromAirport,
            toAirport: item.toAirport
          }
        })
      },
      popActive(index){
        for (var i = 0; i < this.popInfo.length; i++) {
          this.$store.state.flight.popInfo[i].isSelected = false;
          this.$store.state.flight.popInfo[i].popShowCheck = false;
        }
        this.$store.state.flight.popInfo[index].isSelected = true;
        this.$store.state.flight.popInfo[index].popShowCheck = true;
        this.popupVisible1 = false;

        if (index == 0) {
          this.$store.state.flight.sort = 'price_down';
          this.flightAjax();
          ;
        }
        if (index == 1) {
          this.$store.state.flight.sort = 'date_early';
          this.flightAjax();
          ;
        }

      },//排序   点击
      popActive1(index){
        for (var i = 0; i < this.popInfo1.length; i++) {
          this.$store.state.flight.popInfo1[i].isSelected = false;
          this.$store.state.flight.popInfo1[i].popShowCheck = false;
        }
        this.$store.state.flight.popInfo1[index].isSelected = true;
        this.$store.state.flight.popInfo1[index].popShowCheck = true;
        this.popupVisible2 = false;

        switch (index) {
          case 0: //头等舱/公务舱
            this.$store.state.flight.code = 'C,F';
            this.flightAjax();
            break;
          case 1://经济舱
            this.$store.state.flight.code = 'Y';
            this.flightAjax();
            break;
          case 2: //不限
            this.$store.state.flight.code = '';
            this.flightAjax();
            break;
        }


      },//舱位  点击
      tabSel(index){
        for (var i = 0; i < this.tabs.length; i++) {
          this.tabs[i].istab = false;
        }
        this.tabs[index].istab = true;
        this.a = false;
        this.b = false;
        this.c = false;
        this.d = false;
        this.e = false;
        switch (index) {
          case 0:
            this.a = true;
            break;
          case 1:
            this.b = true;
            break;
          case 2:
            this.c = true;
            break;
          case 3:
            this.d = true;
            break;
          case 4:
            this.e = true;
            break;
        }
      },
      shuju(){
        var that = this;
        var state = this.$store.state;
        //        请求成功之前就有值,请求成功之后再对比.  还存在则显示.
        var fromTime = state.flight.fromTimes.split(',');
        var fromAirportNames = state.flight.fromAirportNames.split(',');
        var toAirportNames = state.flight.toAirportNames.split(',');
        var aircrafts = state.flight.aircrafts.split(',');
        var carrierNameShorts = state.flight.carrierNameShorts.split(',');

        //综合筛选初始化
        state.flight.tabInfo = [
          {
            tabInfos: [
              {
                listName: '不限',
                a: true
              },
              {
                listName: '00:00-06:00',
                a: false
              },
              {
                listName: '06:00-12:00',
                a: false
              },
              {
                listName: '12:00-18:00',
                a: false
              },
              {
                listName: '18:00-24:00',
                a: false
              },

            ]
          },//起飞时间
          {
            tabInfos: [
              {
                fromAirport: '不限',
                a: true
              },
            ]
          },//出发机场
          {
            tabInfos: [
              {
                toAirport: '不限',
                a: true
              },
            ]
          },//到达机场
          {
            tabInfos: [
              {
                aircrefTypeName: '不限',
                aircrefType: '',
                a: true
              },
            ]
          },//机型
          {
            tabInfos: [
              {
                carrierName: '不限',
                a: true
              },
            ]
          }//航空公司
        ];
        //综合筛选数据重组
        for (var i = 0; i < state.flight.tabInfo.length; i++) {
          switch (i) {
            case 0://起飞时间
              if (fromTime[0] != '') {
                for (var k = 0; k < fromTime.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (fromTime[k] == state.flight.tabInfo[i].tabInfos[j].listName) {
                      state.flight.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 1: //出发机场
              for (var j = 0; j < state.flight.fromCityForms.length; j++) {
                var obj = {};
                obj.fromAirport = state.flight.fromCityForms[j].fromAirport;
                obj.a = state.flight.fromCityForms[j].checked;
                state.flight.tabInfo[i].tabInfos.push(obj);
              }
              if (fromAirportNames[0] != '') {
                for (var k = 0; k < fromAirportNames.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (fromAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].fromAirport) {
                      state.flight.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 2:  //到达机场
              for (var j = 0; j < state.flight.toCityForms.length; j++) {
                var obj = {};
                obj.toAirport = state.flight.toCityForms[j].toAirport;
                obj.a = state.flight.toCityForms[j].checked;
                state.flight.tabInfo[i].tabInfos.push(obj);
              }
              if (toAirportNames[0] != '') {
                for (var k = 0; k < toAirportNames.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (toAirportNames[k] == state.flight.tabInfo[i].tabInfos[j].toAirport) {
                      state.flight.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 3:  //机型
              for (var j = 0; j < state.flight.aircraftTypes.length; j++) {
                var obj = {};
                obj.aircrefTypeName = state.flight.aircraftTypes[j].aircrefTypeName;
                obj.aircrefType = state.flight.aircraftTypes[j].aircrefType;
                obj.a = false;
                state.flight.tabInfo[i].tabInfos.push(obj);
              }
              if (aircrafts[0] != '') {
                for (var k = 0; k < aircrafts.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (aircrafts[k] == state.flight.tabInfo[i].tabInfos[j].aircrefType) {
                      state.flight.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false;
              }
              break;
            case 4:  //航空公司
              for (var j = 0; j < state.flight.carrierForms.length; j++) {
                var obj = {};
                obj.carrierName = state.flight.carrierForms[j].carrierName;
                obj.a = false;
                state.flight.tabInfo[i].tabInfos.push(obj);
              }
              if (carrierNameShorts[0] != '') {
                for (var k = 0; k < carrierNameShorts.length; k++) {
                  for (var j = 0; j < state.flight.tabInfo[i].tabInfos.length; j++) {
                    if (carrierNameShorts[k] == state.flight.tabInfo[i].tabInfos[j].carrierName) {
                      state.flight.tabInfo[i].tabInfos[j].a = true;
                    }
                  }
                }
                state.flight.tabInfo[i].tabInfos[0].a = false;
              }
              break;
          }
        }
      },
      flightAjax(key){
        var key = key || '';
        var that = this;
        var state = this.$store.state;
        if(!that.toastInfo){
          that.$vux.loading.show({
            text: '加载中...'
          })
        }
        that.updateTime = 0;

        this.$flight.getFlightList({
          fromCityCode: state.flight.fromCityCode,//出发城市code
          toCityCode: state.flight.toCityCode,//到达城市code
          fromCityId: state.flight.fromCityId,//出发城市id
          toCityId: state.flight.toCityId,//到达城市id
          fromDate: state.flight.fromDate,//出发时间
          sort: state.flight.sort,//时间和价格排序方式  默认为从早到晚:date_early 价格从低到高price_down
          code: state.flight.code,//F:头等舱   C:公务舱     Y:经济舱
          isFilter: state.flight.travelPolicyCheck,//差旅政策航班是否勾选

          fromType: state.flight.fromType,
          toType: state.flight.toType,

          fromTimes: state.flight.fromTimes,//出发时间
          fromAirportNames: state.flight.fromAirportNames,//出发机场
          toAirportNames: state.flight.toAirportNames,//达到机场
          aircrafts: state.flight.aircrafts,//机型
          carrierNameShorts: state.flight.carrierNameShorts,//航空公司
        },function (res) {
          clearInterval(that.IntervalTime);
          that.update();//启动定时器
          state.flight.week = res.week; //星期列表
          for (var i = 0; i < state.flight.week.length; i++) {
            if (state.flight.week[i].flag == true) {
              state.flight.Sunday = '周' + state.flight.week[i].week;
            }
          }
          that.$vux.loading.hide();
          if(res.code=== '0' || res.code=== '2' ){//查询返回数据为空 0  查询异常  2
            that.$store.state.flight.noFlight = true;
            that.$store.state.flight.noFlightInfo = res.message;
            that.noList = false;
            return
          }else if(res.code=== '1' || res.code=== '8'){ //根据差旅政策过滤后为空 1
            that.$store.state.flight.noFlight = true;
            that.$store.state.flight.noFlightInfo = res.message;
            that.noList = true;
            state.flight.flightShowDetail = res.flightListForm[0].flightShowDetail;  //详细   所有航班列表
            state.flight.flightForm = res.flightListForm[0].flightForm;
          }else{
            that.$store.state.flight.noFlight = false;
            that.noList = true;
            state.flight.flightShowDetail = res.flightListForm[0].flightShowDetail; //详细   所有航班列表
            state.flight.flightForm = res.flightListForm[0].flightForm;
          }

          state.flight.productGroupMap = res.ProductGroupMap; // 列表详情数据标题

          if (key.date == 2 || key.date == 1) { //如果点击了星期 或者点击了日期控件
            state.flight.fromCityForms = res.fromCityForms;//           出发机场
            state.flight.toCityForms = res.toCityForms;//           到达机场
            state.flight.aircraftTypes = res.aircraftTypes;//           机型
            state.flight.carrierForms = res.carrierForms;//           航空公司
            state.flight.cabinTypeMap = res.cabinTypeMap;//           折扣转换
            state.flight.cabinGradeMap = res.cabinGradeMap;//           舱位转换
            that.shuju();
          }
        },function (err) {
          that.$vux.loading.hide();
        });

      },
    },
    mounted(){
      this.update();
      if (this.$route.query.from == 'flightIndex') {
        var flight = this.$store.state.flight;
        flight.fromTimes = '';
        flight.fromAirportNames = '';
        flight.toAirportNames = '';
        flight.aircrafts = '';
        flight.carrierNameShorts = '';
        this.$store.state.flight.travelPolicyCheck=true;
      }
      this.flightAjax({date: 1});
      //      综合筛选数据初始化
      for (var i = 0; i < this.tabs.length; i++) {
        this.$store.state.flight.tabs[i].istab = false;
      }
      this.$store.state.flight.tabs[0].istab = true;
      this.a = true;
      this.b = false;
      this.c = false;
      this.d = false;
      this.e = false;
      this.selected = this.$store.state.flight.selected;

    },
    watch: {
      date(val, oldVal){
        if (val == oldVal) {
        } else {
        }
      },//重新选择啦日期
      selected(val, oldVal){
      }
    },
    computed: {
      domHeight() {

      },
      openTime(){
        return this.$store.state.flight.fromDate
      },
      max(){
        return '365'.future()
      },
      fromTimes(){
        return this.$store.state.flight.fromTimes;
      }, //出发时间参数
      fromAirportNames(){
        return this.$store.state.flight.fromAirportNames;
      },//出发机场参数
      toAirportNames(){
        return this.$store.state.flight.toAirportNames;
      },//到达机场参数
      aircrafts(){
        return this.$store.state.flight.aircrafts;
      },//机型参数
      carrierNameShorts(){
        return this.$store.state.flight.carrierNameShorts;
      },//航空公司参数
      flight(){
        return this.$store.state.flight
      },
      popInfo(){
        return this.$store.state.flight.popInfo;
      },
      popInfo1(){
        return this.$store.state.flight.popInfo1;
      },
      noFlight(){
        return this.$store.state.flight.noFlight;
      },
      noFlightInfo(){
        return this.$store.state.flight.noFlightInfo;
      },
      tabs(){
        return this.$store.state.flight.tabs;
      },
      tabInfo(){
        return this.$store.state.flight.tabInfo;
      },
      // travelPolicyCheck(){
      //   return this.$store.state.flight.travelPolicyCheck;
      // },
      toFlightData(){
        return this.$store.state.flight.toFlightData
      }// 去程数据展示
    }
  }
</script>


<!--没有符合条件的航班-->
<style scoped>
  .noFlight{
    display: flex;
    padding: 0 .5rem;
    text-align: left;
    height: 2rem;
    background-color: #efefef;
    align-items: center;
  }
</style>

<!--自定义头-->
<style scoped>
  .header {
    background: #46a1bb;
    height: 2.2rem;
    background-size: cover;
    color: #fff;
    display: flex;
    box-sizing: border-box;
    padding: 0 .75rem;
  }

  .backImg {
    flex: 0 0 15%;
    height: 2.2rem;
    line-height: 2.2rem;
    text-align: left;
    background: url('../../../assets/images/back.png') no-repeat left center;
    background-size: .6rem 1.1rem;
  }

  .dateTitle {
    height: 2.2rem;
    flex: 0 0 70%;
    text-align: center;
    line-height: 2.2rem;
    font-size: .8rem;/*px*/
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .way-retuen{

  }
  .dateCity {
    font-size: .9rem; /*px*/
  }

  .dateDate {
    margin-top: 6px;
    font-size: .7rem; /*px*/
  }

  .dateDateL {
    margin-right: .2rem;
  }

  .content{
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .content:after{
    display: block;
    content: '';
  }
</style>


<!--综合筛选-->
<style scoped>
  /*筛选结果*/

  .empty{
    height: 1rem;
    line-height: 1rem;
    color: #0094db;
    font-size: .75rem;/*px*/
    float: right;
    margin-bottom: .5rem;
    margin-top: .5rem;
    margin-right: 1.5%;
  }

  .filterBox{
    border-top: 1px solid #ddd;
    padding: .25rem .45rem  0 .45rem;
  }

  .showSel{
    /*height: 10.5rem;*/
    overflow: auto;
  }

  .showSelItem{
    border: 1px solid #0094db;/*no*/
    width: 47%;
    height: 1.4rem;
    line-height: 1.4rem;
    color: #0094db;
    font-size: .65rem;/*px*/
    float: left;
    margin: .25rem 1.5% 0;
    box-sizing: border-box;
  }

  .showSelItem1{
    float: left;
    margin-left: .25rem;
    margin-right: .25rem;
  }
  .showSelItem2{
    float: left;
  }
  .showSelItem3{
    float: right;
    margin-right: .25rem;
  }

  /*筛选条件*/
  .tabBox{
    display: flex;
    width: 100%;
    border-top: 1px solid #ddd;/*no*/
  }


  .queren{
    height: 2.5rem;
    width: 100%;
    background-color: #46a1bb;
    text-align: center;
    line-height: 2.5rem;
    color: #fff;
    font-size: .9rem;/*px*/
  }


  .mint-popup-bottom {
    width: 100%;
  }

  .tab {
    flex:  0 0 30%;
    font-size: .75rem;/*px*/
  }

  .tabInfo {
    flex:  0 0 70%;
    height: 12.5rem;
    overflow: auto;
  }

  .tabInfoSubL {
    font-size: .75rem;/*px*/
    margin-left: 1.2rem;
  }

  .tabInfoSubR {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: .75rem 1.5rem;
    border: 1px solid #0094db;/*no*/
  }

  .tabInfoSubR1 {
    float: right;
    width: .75rem;
    height: .75rem;
    margin: 0px 1.5rem;
    font-size: .75rem;/*px*/
    color: #0094db;
  }

  .tabItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 100%;
    background-color: #fff;
    text-align: center;
    border-bottom: 1px solid #ddd;/*no*/
    border-right: 1px solid #ddd;/*no*/
  }

  .tab .activeTabItem{
    background-color: #46a1bb;
    border-right: none;
    color: #fff;
  }

  .tabInfoItem {
    height: 2.5rem;
    line-height: 2.5rem;
    width: 100%;

  }

  .tabInfoItem label{
    width: 100%;
    height: 100%;
    display: block;
    margin: auto;
    border-bottom: 1px solid #ddd;/*no*/
  }


</style>

<style scoped>
  .popItem {
    line-height: 2.5rem;
    width: 100%;
    border-bottom: 1px solid #ddd;/*no*/
    font-size: .75rem; /*px*/
    box-sizing: border-box;
    padding: 0 1.2rem;
  }

  .activePop {
    color: #0994db;
  }

</style>

<style scoped>

  .carrierInfo{
    padding: .25rem 0;
    float: left;
  }

  .lowPrice{
    background-color:#f60;
    color: #fff;
    float: right;
    padding: .25rem;
    border-radius: .2rem;
  }


  .box {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background-color: #fff;
  }

  .flightType {
    margin-top: .25rem;
  }


  .money {
    color: #f60;
    font-size: .9rem; /*px*/
    margin-bottom: .2rem;
    text-align: right;
  }
  .Ticket{
    text-align: right;
    color: #f60;
  }
  .moneyIco{
    font-size: .65rem;/*px*/
  }

  .startDate {
    font-size: .9rem; /*px*/
    margin-bottom: .4rem;
    color: #333;
  }

  .toDate{
    font-size: .9rem; /*px*/
    margin-bottom: .4rem;
    color: #333;
  }

  .list {
    padding: .75rem .5rem;
    color: #888;
    border-bottom: 1px solid #eee;/*no*/
  }

  .liL {
    width: 5.75rem;
    text-align: left;
  }
  .listSub {
    display: flex;
    width: 100%;
  }
  .listSub .liR {
    float: right;
  }

  .liM {
    text-align: right;
  }

  .liLine {
    flex: 0 0 2.25rem!important;
    height: .25rem;
    background: url("../../../assets/images/goBackLine90.png") no-repeat;
    margin: .75rem 5px;
    background-size: cover;
  }

  .listSub > div {
   flex: 1;
  }

  .outer {
    width:100%;
    position: relative;
    height: 100%;
    font-size: .6rem;/*px*/
    -webkit-overflow-scrolling: touch;
    -overflow-scrolling: touch;
    overflow: hidden;
    background-color: #fff;
  }
  .outer ::-webkit-scrollbar {
    display: none;
  }

  .main {
    background-color: #fff;
    overflow: hidden;
    position: relative;
  }
  .main-height {
    height: calc(100% - 11.7rem);
    margin-top: 9.2rem;
  }
  .no-main-height {
    height: calc(100% - 9.7rem);
    margin-top: 7.2rem;
  }
  .title {
    color: #fff;
    background-color: #46a1bb;
    height: 3rem;
    display: flex;
  }
  .container {
    position: absolute;
    top:50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    padding: 0 .25rem;
    box-sizing: border-box;
  }
  .container>div {
    flex: 1;
  }
  .dateTab {
    position: relative;
    flex: 0 0 90%;
  }

  .itemDate {
    float: left;
    width: 10%;
    text-align: center;
    padding: .25rem 0;
    border-radius: .25rem;
    font-size: .6rem;/*px*/
  }

  .itemDateNum {
    margin-top: .25rem;
  }

  .dateImg {
    color: #3e3a39;
    flex: 0 0 10%;
    text-align: center;
    /*height: 1.75rem;*/
    background: url("../../../assets/images/calendar.png") no-repeat center center;
    background-size: 1.05rem 1.15rem ;
  }


</style>

<!--底部tab-->
<style scoped>
  .iconfont {
    font-size: .9rem; /*px*/
  }

  footer {
    height: 2.5rem;
    position: fixed; /*不加固定定位是block加高度的,会把父级撑开.加了之后脱离文档流*/
    right: 0;
    bottom: 0;
    left: 0;
  }

  footer .mint-tabbar {
    font-weight: bold;
  }

  footer .mint-tab-item {
    padding: .375rem 0;
  }

  footer .mint-tab-item-label {
    font-size: .55rem; /*px*/
    margin-top: .25rem;
  }

  footer .mint-tabbar > .mint-tab-item.is-selected {
    color: #46a1bb;
  }

  footer .mint-tab-item-icon {

  }

  .mint-navbar .mint-tab-item {
    padding: .25rem 0;
    font-size: .6rem;/*px*/
  }

  .mint-navbar .mint-tab-item p {
    font-size: .6rem;/*px*/
  }

  .is-selected {
    border: none;
    background-color: rgba(255,255,255,.3);
    color: #fff;
    margin-bottom: 0;
  }

  .mint-navbar {
    background-color: #0d496b;
  }
  .changePop{
    width: 92%;
    margin: 0 auto 20rem;
    height: 5rem;
    /* padding: .5rem .75rem;*/
    /* overflow: scroll;*/
  }
  .poplist{
    width: 100%;
    height: 5rem;
    padding-top: .5rem;
  }
  .poplist span{
    display: inline-block;
    height: .75rem;
    width: 2.5rem;
    float: left;
  }
  .L{
    width: 5.75rem;
    text-align: left;
    margin-left: .75rem;
  }
  .L >p{
    margin-top: .375rem;
    text-align: center;
  }
  .M{
    width: 5.25rem;
    padding-left: .5rem;
    text-align: center;
  }
  .M >.liLine {
    width: 3rem;
    height: .25rem;
    background: url("../../../assets/images/goBackLine90.png") no-repeat;
    /* margin: .75rem 5px;*/
    margin-top: .5rem;
    background-size: cover;
  }
  .R{
    float: right;
  }
  .R > P{
    margin-top: .375rem;
    text-align: center;
  }
  .line{

    margin-top: .25rem;
  }
  .poplist >div{
    float: left;
  }
  .p4{
    margin-left: -1.5rem;
  }
  .p2{padding: 0}
  .p5{
    text-align: left;
    margin-left: .5rem;
    padding: 0 !important;
  }
  .p1{margin-top: 0 !important;}
  .p6{margin-top: 0 !important;}
</style>

<!--仅显示符合差旅标准的航班-->
<style scoped>
  .travelPolicy{
    padding: 0 .75rem;
    border-bottom: 1px solid #ccc;/*no*/
    line-height: 2rem;
    height: 2rem;
    font-size: .7rem;/*px*/
    display: flex;
    box-sizing: border-box;
  }

  .travelPolicy input[type=checkbox]{
    /*flex: 10%;*/
    height: .8rem;
    margin-top: .55rem;
    width:.8rem;
  }
  .icons-qu{
    background-color: #0c80ba;
    padding: .1rem;
    border-radius: 2px;
    color: #FFFFFF;
  }
  .label{
    flex: 90%;
    color: #666;
  }
  .positiontop{

  }
  .head-qu{
    padding-top: .5rem;
    padding-left: .5rem;
  }
  .head-span{
    font-size: .75rem;/*px*/
  }
</style>

